<?php

use App\Http\Controllers\Backend\AuthController;
use App\Http\Controllers\Backend\CaptchaController;
use App\Http\Controllers\Backend\Content\ArticleController;
use App\Http\Controllers\Frontend\Content\ArticleController as FrontArticleController;
use App\Http\Controllers\Backend\Content\CategoryController;
use App\Http\Controllers\Frontend\Content\CategoryController as FrontCategoryController;
use App\Http\Controllers\Backend\LoginController;
use App\Http\Controllers\Backend\SettingController;
use App\Http\Controllers\Backend\System\MenuController;
use App\Http\Controllers\Backend\System\RecordController;
use App\Http\Controllers\Backend\System\RoleController;
use App\Http\Controllers\Backend\System\UserController;
use App\Http\Controllers\Backend\WechatController;
use App\Http\Controllers\FileController;
use App\Http\Middleware\AuthMiddleware;
use App\Http\Middleware\GuestMiddleware;
use App\Http\Middleware\UploadFileMiddleware;
use App\Http\Middleware\WechatMiddleware;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::get('/user', function (Request $request) {
    return $request->user();
})->middleware('auth:sanctum');


//登录
Route::post('login',[LoginController::class,'login']);

Route::get('captcha',[CaptchaController::class,'captcha']);

Route::any('weixin',[WechatController::class,'serve'])->middleware(WechatMiddleware::class);

Route::middleware(AuthMiddleware::class)->group(function (){
    //基本信息
    Route::controller(AuthController::class)->group(function (){
        Route::get('auth/user','userInfo');
        Route::put('auth/password','editPassword');
    });

    //监控页
    Route::controller(MonitorController::class)->group(function (){
        Route::get('/article/monitor','getMonitor');
    });
    //用户管理
    Route::controller(UserController::class)->group(function (){
        Route::get('system/user/page','getUserPage');
        Route::get('system/user/existence','existence');
        Route::get('system/user/{id}','getUserInfo');
        Route::post('system/user','createUser');
        Route::put('system/user/status','updateUserStatus');
        Route::put('system/user','updateUser');
        Route::put('system/user/password','resetPassword');
        Route::delete('system/user/batch','deleteUserBatch');
        Route::delete('system/user/{id}','deleteUser');
        Route::get('system/gender','getGenderList');
    });

    //角色管理
    Route::controller(RoleController::class)->group(function (){
        Route::get('system/role','getRoleAll');
        Route::get('system/role/page','getRolePage');
        Route::post('system/role','createRole');
        Route::put('/system/role','updateRole');
        Route::put('/system/role-menu/{id}','updateRoleMenu');
        Route::delete('system/role/batch','deleteRoleBatch');
        Route::delete('system/role/{id}','deleteRole');
    });

    //菜单管理
    Route::controller(MenuController::class)->group(function (){
        Route::get('/system/role-menu/{id}','getRoleMenu');
        Route::get('system/menu','getMenuAll');
        Route::post('system/menu','createMenu');
        Route::put('system/menu','updateMenu');
        Route::delete('system/menu/{id}','deleteMenu');
    });

    //日志管理
    Route::controller(RecordController::class)->group(function (){
        Route::get('system/login-record/page','getLoginRecordPage');
        Route::get('system/operation-record/page','getOperateRecordPage');
    });

    //---------------------------begin------------------------//
    //文章分类管理
    Route::controller(CategoryController::class)->group(function (){
        Route::get('content/category','getCategories');
        Route::get('content/category/{id}','getCategory');
        Route::post('content/category','addCategory');
        Route::put('content/category','updateCategory');
        Route::delete('content/category/{id}','deleteCategory');
    });

    //文章列表管理
    Route::controller(ArticleController::class)->group(function (){
        Route::get('content/article/page','getArticlePage');
        Route::post('content/article','addArticle');
        Route::put('content/article','updateArticle');
        Route::put('content/article/status','changeArticleStatus');
        Route::delete('content/article/{id}','deleteArticle');
        Route::get('article/count','getCount');
    });

    //文件上传
    Route::controller(FileController::class)->group(function (){
        Route::post('file/upload','uploadFile')->middleware(UploadFileMiddleware::class);
    });
    //--------------------end-------------------------//


    //通知管理
    Route::controller(NoticeController::class)->group(function (){
        Route::get('notice','getNotices');
        Route::get('notice/clear','clearNotices');
    });

    //站点配置
    Route::controller(SettingController::class)->group(function (){
        Route::get('setting/get','getConfig');
        Route::post('setting/update','updateConfig');
    });

    //微信
    Route::controller(WechatController::class)->middleware(WechatMiddleware::class)
        ->group(function (){
        Route::get('wechat/getMaterial','getMaterial');
        Route::get('wechat/getMaterialList','getMaterialList');
        Route::get('wechat/getWxMenu','getWxMenu');
        Route::post('wechat/addWxMenu','addWxMenu');
    });

    //公司管理
    Route::controller(CompanyController::class)->group(function (){
        Route::get('employ/company/existence','existence');
        Route::get('employ/company/page','getCompanyPage');
        Route::get('employ/company','getCompanyAll');
        Route::post('employ/company','createCompany');
        Route::put('employ/company','updateCompany');
        Route::put('employ/company/status','updateCompamyStatus');
        Route::delete('employ/company/batch','deleteCompanyBatch');
        Route::delete('employ/company/{id}','deleteCompany');

    });

    //职位分类管理
    Route::controller(EcategoryController::class)->group(function (){
        Route::get('employ/category/page','getCategoryPage');
        Route::get('employ/category','getCategoryAll');
        Route::post('employ/category','createCategory');
        Route::put('employ/category','updateCategory');
        Route::delete('employ/category/batch','deleteCategoryBatch');
        Route::delete('employ/category/{id}','deleteCategory');
    });

    //职位福利管理
    Route::controller(EtagsController::class)->group(function (){
        Route::get('employ/tags/page','getTagPage');
        Route::get('employ/tags','getTagsAll');
        Route::post('employ/tags','createTag');
        Route::put('employ/tags','updateTag');
        Route::delete('employ/tags/batch','deleteTagBatch');
        Route::delete('employ/tags/{id}','deleteTag');
    });

    //职位管理
    Route::controller(EjobController::class)->group(function (){
        Route::get('employ/jobs/page','getJobPage');
        Route::post('employ/jobs','createJob');
        Route::put('employ/jobs','updateJob');
        Route::put('employ/jobs/status','updateJobStatus');
        Route::delete('employ/jobs/batch','deleteJobBatch');
        Route::delete('employ/jobs/{id}','deleteJob');
    });
    //会议管理
    Route::controller(MeetingController::class)->group(function (){
        Route::get('sign/meeting/page','getMeetPage');
        Route::get('sign/users','listUsers');
        Route::post('sign/meeting','addMeeting');
        Route::put('sign/meeting','updateMeeting');
        Route::put('sign/userSeat','userSeat');
        Route::delete('sign/meeting/batch','deleteMeetingBatch');
        Route::delete('sign/meeting/{id}','deleteMeeting');
    });
    //消息管理
    Route::controller(MessageController::class)->group(function (){
        Route::get('user/message','getMessage');
        Route::get('user/notice','getUnreadMessage');
    });
    //个人信息
    Route::controller(ProfileController::class)->group(function (){
        Route::post('user/avatar','saveAvatar');
        Route::post('user/profile','updateProfile');
    });

    //清除缓存
    Route::get('clear-cache',[CacheController::class,'clear']);
});

Route::middleware(GuestMiddleware::class)->group(function (){
    //内容管理
    Route::controller(FrontCategoryController::class)->group(function (){
        Route::get('front/content/category','getCategory');
        Route::get('front/content/category/info','getCateInfo');
        Route::get('front/content/category/son','getCateChild');
    });
    Route::controller(FrontArticleController::class)->group(function (){
        Route::get('front/content/list','getArticleList');
        Route::get('front/content/detail','getArticleDetail');
    });
    //招聘信息
    Route::controller(FrontJobController::class)->group(function (){
        Route::get('/employ/job/page','getJobPage');
        Route::get('/employ/cate','getCategory');
        Route::get('/employ/company','getCompanyList');
        Route::get('/employ/job/{id}','getJobFirst');
        Route::get('/employ/company/{id}','getCompanyFirst');
    });

    //微信配置
    Route::controller(SettingController::class)->group(function (){
        Route::get('front/wechat/setting','getWechatConfig');
    });

    //会议签到
    Route::controller(FrontMeetingController::class)->group(function(){
        Route::get('sign/meeting/{id}','getMeetingInfo');
        Route::get('sign/check/register','checkRegister');
        Route::post('sign/register','register');
        Route::post('sign/entry','entryMeeting');
        Route::post('sign/sign','signMeeting');
        Route::post('sign/check/entry','checkEntry');
        Route::post('sign/check/sign','checkSign');
        Route::get('sign/entryUser','getEntryUser');
        Route::get('sign/signInfo','getSignInfo');
        Route::get('sign/signUser','getSignUser');
    });
});
